---
title: "_READ-ME_State Terror and Long-run Development: The Persistence of the Khmer Rouge"
author: "Don Grasse"
date: "2023-03-19"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Replication Instructions 

This is the read me file for replication of the manuscript ``State Terror and Long-run Development: The Persistence of the Khmer Rouge.'' 

### Data in Data Folder 
The replication package includes the following datasets and scripts to produce results.  

Dataframes for analysis: 
\begin{itemize}
\item Dataframe of 2008 villages: `main\_0310.rds' 
\item Dataframe of 1998 villages: `census\_1998\_0310.rds'
\item Dataframe of spatial outcomes for balance: `grid1x1\_2022.rds'
\item Dataframe of villages for placebo analysis: `NR3df.rds'
\item Dataframe of commune polygons: 'gadm36\_KHM\_3\_sf.rds'
\item Dataframe of province polygons: 'gadm36\_KHM\_1\_sf.rds'
\item Dataframe of Violence Against Women Survey: 'VAW Cambodia 2015 original full STATA9.dta'
\item Dataframe for Grid Cell Elevation used for Figure 2: `grid\_cell\_df\_map.rds'
\item Dataframe of Commune Election Results: eledf.rds
\item Dataframe of Commune Migration: 'im\_df.rds'
\item Shapefile of schools: 'school\_of\_cambodia.shp'
\item Survey of EWR exposure: 'baselinesurveymineerw'
\item Causalities from landmines and EWR: 'mine-and-erw-causality-2005-2013'
\item Shapefile of prisons, mass graves, memorials from DK 'prisons\_burials\_memorials'
\item Shapefile of roads: 'Major\_Roads'
\item Shapefile of rivers: 'Major\_Rivers' 
\item DK era zones: 'Democratic\_Kampuchea\_Zones'
\end{itemize}

Individual level microdata used to study the impacts of the regime on individual health, labor market outcomes, and wealth, are provided by the National Institute of Statistics Cambodia (NIS) and the Demographic Health Survey (DHS). These data cannot be provided for replication. Instead, an interested scholar must contact these organizations to receive the data for themselves. Further information is provided in the data-access-developmental-legacies-of-dictatorship.rtf file. 

Dataframes that cannot be included in the replication files but are required to reproduce the main results include 
\begin{itemize}
\item Dataframe of education by cohorts: `educDD.rds'
\item Dataframe of children health: `dhs\_kr.rds'
\item Dataframe of individual wealth data from DHS `dhs\_df.rds'
\item Dataframe of individual income from LFS `lfs\_income.rds'
\item Folder of DHS data including survey clusters 'DHS'
\item DHS clusters from 2000-2014 'dhs\_shape\_stack.rds'
\end{itemize}

## Analysis 

The file \_main.R will load all necessary packages, extra functions, and data to produce all figures and tables that appear in the main text and appendix. A scholar interested in reproducing just one figure or table can do so using the argument source(.) where . refers to the name of the script that the scholar seeks to recreate. Note that tables are edited in .tex for aesthetics, and thus the output does not exactly match what appears in the final .PDFs, where additional labels and notes are added manually to improve transparency and readability.

A researcher wishing to reproduce an individual table or figure can do so by looking inside of the tabs-in or figs-in folder. Each table and figure is named as it appears in the manuscript - for instance, code to produce Table 2 in the main text is in tab2-baseline-in.R and Figure A1 is in figA1-balance-in.R. 

\textbf{PLEASE NOTE:} Since the data required to conduct the entire analysis cannot be shared by the author, the script \_main.R will not run cleanly, because it will seek to use data that does not exist in the data folder I was able to make available. As such, one will need to obtain the necessary data to run the entire script themselves. 

The file packages.R includes all packages necessary for the analysis. Again, if a researcher wishes to produce just an individual table or figure, they will want to consult the packages.R script to load everything that is necessary.

The file grd-helper-functions.R includes functions created by the author to conduct the analysis. 

As always, take care to set the working directory! Each individual script assumes you have loaded the packages and set the working directory as set in the _main.R script. So make sure you check that first even if you just want to look at one particular table/figure. 

## Technical Information  

```{r, echo = F, results='asis'}
m <- sessionInfo()
```
R version 4.2.1 (2022-06-23) \\\\
Platform: x86_64-apple-darwin17.0 (64-bit) \\\\
Running under: macOS Monterey 12.3.1

Please note that the robust standard error estimation is computationally expensive because the range of the spatial autocorrelation is being estimated with MLE to inform how much spatial dependence should be tolerated when constructing uncertainty estimates. As such, many of the models take a long time...if there seems to be a delay, nothing is wrong with your machine, just trust the process. 

## Questions?
Questions? Please contact Donald Grasse \<donald dot grasse dot 93 at gmail dot com\>. 



